bot = Bot(qq,"密码")
bot:login()
bot:join()
--点歌插件
song_singers = {} song_names = {} pic_urls = {} song_ids = {}
--以图搜图
sender_id = ""
--QQ复读机
rep_num = 1 rep_t = {} rep_res = "" rep_t[1] = ""

bot:subscribeGroupMsg(
    function(bot, msg, group, sender)
		require("api")
		--点歌插件
		if msg:find("点歌") then
			song_singers = {} song_names = {} pic_urls = {} song_ids = {}
			value = msg:gsub("点歌","")
			res = music_tables(value)
			group:sendMsg(res)
		end
	    if msg:find("#%d+") then
	        if not msg:find("source") then
    			num = msg:gsub("#","")
    			num = tonumber(num)
    			res = music_look(num)
    			group:sendMsg(App(res))
    		end
	    end	
		--以图搜图
		if msg:find("以图搜图") then
		    for i,m in ipairs(msg:toTable()) do
            	if (m:find("mirai:image")) then
                    x = m:getImageUrl()
                    group:sendMsg("请稍等")
                    pic, res = find_pic(x)
				    group:sendMsg(Image(pic,group) .. res)
                end
            end
        end
        if msg == "以图搜图" then
			sender_id = sender.id
			group:sendMsg("请发送一张图片")
		end
		if msg:find("mirai:image") then
		    x = msg:getImageUrl()
			value = sender.id
			if sender_id == value then
				group:sendMsg("请稍等")
				sender_id = ""
				pic, res = find_pic(x)
				group:sendMsg(Image(pic,group) .. res)
			end
		end
		
		--签到奖励
		if msg == "签到" then
			s = tostring(os.date("%Y%m%d", os.time()) .. group.id .. sender.id)
			x = readdata()
			if x:find(s) then
				group:sendMsg("你今天已经签到过了!!!")
			else
				url = Http.getRedirectUrl("http://api.btstu.cn/sjbz/?lx=m_dongman"):gsub("http://api.btstu.cn","")
				group:sendMsg(Image(url,group) .. At(sender) .. "签到成功,这是你的签到奖励")
				writedata(s)
			end
		end
		--QQ复读机
		if msg:find(msg) then
			rep_num = rep_num + 1
			rep_t[rep_num] = msg
		end
		if rep_t[rep_num-1] == rep_t[rep_num] then
		    if rep_res == "" then
    			group:sendMsg(msg)
    			rep_res = msg
    		end
		end
		if rep_res ~= rep_t[rep_num] then
		    rep_res = ""
		end		
	end
)